package com.trailwalker.inputmethod;

import com.trailwalker.JavaUtils.log.LogUtils;
import com.trailwalker.inputmethod.activity.InputMethodMainActivity;
import com.trailwalker.inputmethod.service.data.InputMethodDataService;
import com.trailwalker.javafx.core.activity.Activity;
import com.trailwalker.javafx.core.application.JavaFxApplication;
import com.trailwalker.javafx.core.entity.Intent;
import com.trailwalker.javafx.utils.resource.ResourceUtils;
import javafx.scene.Scene;

/**
 * @author Trailwalker
 * @create 2021-08-31 11:18
 * @des
 */
public class InputMethodApplication extends JavaFxApplication {

    private static final String TAG = InputMethodApplication.class.getSimpleName();

    private InputMethodDataService inputMethodDataService;

    /**
     * main线程
     *
     * @param args
     */
    public static void main(String[] args) {
        LogUtils.log(TAG, "application main work at Thread:" + Thread.currentThread().getName());
        launch(args);
    }

    public InputMethodDataService getInputMethodDataService() {
        return inputMethodDataService;
    }

    @Override
    public void onApplicationInit() {
        inputMethodDataService = new InputMethodDataService();
        inputMethodDataService.createTable();
    }

    @Override
    public void onApplicationStart() {
        Scene scene = getScene();
        scene.getStylesheets().add(ResourceUtils.getCss(this, "darkTheme.css"));
    }

    @Override
    public void onApplicationStop() {
        if (inputMethodDataService != null) {
            inputMethodDataService.release();
        }
    }

    @Override
    public Intent initMainActivity() {
        Intent intent = new Intent(InputMethodMainActivity.class);
        return intent;
    }
}
